 <template>
    <div class="branch-body">
        <div class="branch-header"><div class="header-logo"><img :src="headerLogo"></div></div>
        <div class="branch-container">
            <div class="branch-con" v-for="(item,index) in items" :key="index" v-on:click="toClick(item.Id,item.ShortName,item.LOGO)">
                <div class="branch-left"><img :src="item.LOGO"></div>
                <div class="branch-right">
                    <h2>{{item.ShortName}}</h2>
                    <p>{{item.CurrentPeriod}}</p>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import axios from '../util/axios';
export default {
    data() {
        return {
            items: {},
            headerLogo: 'static/content/images/header/logo.png',
            defaultLogo:'static/content/images/Header-S.png'
        }
    },
    created() {
        this.clear();
        const auth = localStorage.getItem('user');
        //如果账号不存在就直接跳到登录
        if (!auth) {
            this.$router.replace("/login")
        } else {
            this.$notify({
                message: auth + " 成功登陆",
                title:'成功',
                type: 'success',
                duration: 1000
            })
            axios.get("selectOrganize").then(data => {
                this.items = data;
                this.items.forEach((item)=>{
                    if(item.LOGO===null){
                        item.LOGO = this.defaultLogo;
                    }
                })
            }).catch(err => {
                console.log(err);
            })
        }
    },
    methods: {
        clear(){
           window.localStorage.removeItem("fffffB");
            window.localStorage.removeItem("fffffK");
            window.localStorage.removeItem("fffffC");
            window.localStorage.removeItem("fffffD");
            window.localStorage.removeItem("fffffG");
            window.localStorage.removeItem("fffffY");
            window.localStorage.removeItem("fffffGYS");
            window.localStorage.removeItem("fffffYJ");
        },
        toClick(id,name,Logo) {
            axios.post('toIndex',{ companyId:id }).then(data => {
                if (data == "True") {
                    this.$router.push({ path: '/Home', params: { companyId: id } });
                    const companyName = localStorage.setItem('ShortName',name);          
                    const logo = localStorage.setItem('LOGO',Logo);
                } else {
                    alert(data);
                }
            }).catch(err => {
                console.log(err);
            })
            
        }
    }
}
</script>
<style lang="scss" scoped>
.branch-body {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: #e9edf0;
    .branch-header {
        width: 100%;
        height: 70px;
        line-height: 70px;
        background-color: #136db1;
        .header-logo{
            width:220px;     
            img {
                margin-left: 25px;
                width:100%;
                vertical-align: middle;
                margin-top: -80px;
            }
        }
    }
    .branch-container {
        margin: 20px auto;
        width: 1000px;
        height: 140px;
        .branch-con {
            width: 300px;
            height: 140px;
            background-color: #FFF;
            float: left;
            margin: 10px 15px;
            border-radius: 5px;
            box-shadow: 0 0 5px 1px #DDD;
            cursor: pointer;
            border: 1px solid transparent;
            .branch-left {
                width: 145px;
                height: 140px;
                line-height: 140px;
                text-align: center;
                float: left;
                img {
                    vertical-align: middle;
                    width: 90px;
                    height: 90px;
                    border-radius: 45px;
                }
            }
            .branch-right {
                width: 155px;
                height: 140px;
                float: left;
                h2 {
                    font-size: 15px;
                    font-weight: bold;
                    margin-top: 40px;
                }
                p {
                    color: #4c6486;
                    margin-top: 30px;
                }
            }
        }
    }
}
</style> */